<% add_decidim_page_title(t(".invite_attendee")) %>
<div class="item_show__header">
  <h1 class="item_show__header-title">
    <%= t(".invite_attendee") %>
  </h1>
</div>
<div class="item__edit item__edit-1col">
  <div class="item__edit-form">
    <%= decidim_form_for(@form, url: meeting_registrations_invites_path, method: :post, html: { class: "form form-defaults new_meeting_registration_invite" }) do |f| %>
      <% disable_form = !allowed_to?(:invite_attendee, :meeting, meeting:) %>

      <%= render partial: "form", object: f, locals: { disabled: disable_form } %>

      <% unless meeting.registrations_enabled? %>
        <div class="text-alert">
          <p><%= t(".registrations_disabled") %></p>
        </div>
      <% end %>
    <% end %>

    <div class="mt-4">
      <%= admin_filter_selector %>
    </div>

    <div class="card" id="meeting-invites">
      <div class="card-divider">
        <h2 class="card-title"><%= t(".invites") %></h2>
      </div>
      <div class="table-scroll">
        <table class="table-list">
          <thead>
            <tr>
              <th><%= t("models.invite.fields.name", scope: "decidim.meetings") %></th>
              <th><%= t("models.invite.fields.email", scope: "decidim.meetings") %></th>
              <th><%= t("models.invite.fields.sent_at", scope: "decidim.meetings") %></th>
              <th><%= t("models.invite.fields.status", scope: "decidim.meetings") %></th>
            </tr>
          </thead>
          <tbody>
            <% @invites.each do |invite| %>
              <% presenter = Decidim::Meetings::InvitePresenter.new(invite) %>
              <tr data-id="<%= invite.id %>">
                <td>
                  <%= invite.user.name %>
                </td>
                <td>
                  <%= invite.user.email %>
                </td>
                <td>
                  <% if invite.sent_at %>
                    <%= l invite.sent_at, format: :decidim_short %>
                  <% end %>
                </td>
                <td class="<%= presenter.status_html_class %>">
                  <%= presenter.status %>
                </td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>
    </div>
    <%= decidim_paginate @invites %>
  </div>
</div>
